<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:rich="http://richfaces.org/rich">
<h:body>
    <ui:composition template="template.xhtml">
        <ui:define name="content">
            <br />
            <h:outputText value="#{msg.guestbook_overview}" styleClass="h1" />
            <br />
            <br />
            <h:panelGrid columns="3">
                <h:outputText value="#{msg.guestbook_overview_user}" styleClass="h2" />
                <h:outputText value="#{sessionBean.username}" styleClass="h3" />
                <h:graphicImage library="img" name="user.jpg" />
            </h:panelGrid>
            <h3>
                <h:outputText value="Wegen dem Profilfoto: Nicht einmal das Beispiel funktioniert und den Error finde ich online nirgends ausser bei internen Fehlerberichten dokumentiert. LG Thomas" />
            </h3>
            <h:link outcome="fileUploadTest">
                <h:outputText value="Nicht funktionierendes, angegebenes Beispiel." />
            </h:link>
            <br />
            <h:link outcome="guestbookProfilePictureUpload">
                <h:outputText value="Nicht funktionierender, abgeänderter Fileupload für Profilfoto." />
            </h:link>
            <br />
            <br />
            <h:link outcome="guestbookCreateEntry">
                <h:outputText value="#{msg.guestbook_overview_action_create}" />
            </h:link>
            <br />
            <h:form>
                <rich:dataTable id="guestbookEntries" value="#{guestbookBean.guestbookEntries}" var="entry">
                    <f:facet name="noData">#{msg.guestbook_overview_nodata}</f:facet>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.guestbook_overview_name}" />
                        </f:facet>
                        <h:outputText value="#{entry.name}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.guestbook_overview_email}" />
                        </f:facet>
                        <h:outputText value="#{entry.email}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.guestbook_overview_postDate}" />
                        </f:facet>
                        <h:outputText value="#{entry.postDate}">
                            <f:convertDateTime pattern="dd.MM.yyyy HH:mm:ss" timeZone="GMT+1" />
                        </h:outputText>
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.guestbook_overview_title}" />
                        </f:facet>
                        <h:outputText value="#{entry.title}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.guestbook_overview_text}" />
                        </f:facet>
                        <h:outputText value="#{entry.text}" />
                    </rich:column>
                    <rich:column>
                        <f:facet name="header">
                            <h:outputText value="#{msg.guestbook_overview_action}" />
                        </f:facet>
                        <h:link outcome="guestbookUpdateEntry" style="margin-right: 10px;" rendered="#{(entry.name == sessionBean.username) or sessionBean.username == 'admin'}">
                            <h:graphicImage library="img" name="edit-icon.png" height="12" alt="#{msg.guestbook_overview_action_edit}" />
                            <f:param name="entryId" value="#{entry.id}" />
                        </h:link>
                        <h:commandLink action="#{actionsBean.deleteEntry}" immediate="true" rendered="#{(entry.name == sessionBean.username) or sessionBean.username == 'admin'}">
                            <h:graphicImage library="img" name="delete-icon.png" height="12" alt="#{msg.guestbook_overview_action_delete}" />
                            <f:setPropertyActionListener target="#{actionsBean.entry}" value="#{entry}"></f:setPropertyActionListener>
                        </h:commandLink>
                    </rich:column>
                </rich:dataTable>
                <br />
                <h:commandButton action="#{logoutBean.logout}" value="#{msg.guestbook_overview_action_logout}" />
            </h:form>

        </ui:define>
    </ui:composition>
</h:body>
</html>
